package com.lineage.server.model.skill.skillmode;

import com.lineage.server.datatables.NpcTable;
import com.lineage.server.model.Instance.L1NpcInstance;
import com.lineage.server.model.Instance.L1PcInstance;
import com.lineage.server.model.Instance.L1SummonInstance;
import com.lineage.server.model.L1Character;
import com.lineage.server.model.L1Magic;
import com.lineage.server.serverpackets.S_ServerMessage;
import com.lineage.server.serverpackets.ServerBasePacket;
import com.lineage.server.templates.L1Npc;

public class LESSER_ELEMENTAL extends SkillMode {
  public int start(L1PcInstance srcpc, L1Character cha, L1Magic magic, int integer) throws Exception {
    int dmg = 0;
    L1PcInstance pc = (L1PcInstance)cha;
    int attr = pc.getElfAttr();
    if (attr != 0) {
      if (!pc.getMap().isRecallPets()) {
        pc.sendPackets((ServerBasePacket)new S_ServerMessage(353));
        return 0;
      } 
      int petcost = 0;
      Object[] petlist = pc.getPetList().values().toArray();
      Object[] array;
      int length = (array = petlist).length;
      int i = 0;
      while (i < length) {
        Object pet = array[i];
        petcost += ((L1NpcInstance)pet).getPetcost();
        i++;
      } 
      if (petcost == 0) {
        int summonid = 0;
        switch (attr) {
          case 1:
            summonid = 45306;
            break;
          case 2:
            summonid = 45303;
            break;
          case 4:
            summonid = 45304;
            break;
          case 8:
            summonid = 45305;
            break;
        } 
        if (summonid != 0) {
          L1Npc npcTemp = NpcTable.get().getTemplate(summonid);
          L1SummonInstance summon = new L1SummonInstance(npcTemp, (L1Character)pc);
          summon.setPetcost(pc.getCha() + 7);
        } 
      } 
    } 
    return 0;
  }
  
  public int start(L1NpcInstance npc, L1Character cha, L1Magic magic, int integer) throws Exception {
    int dmg = 0;
    return 0;
  }
  
  public void start(L1PcInstance srcpc, Object obj) throws Exception {}
  
  public void stop(L1Character cha) throws Exception {}
}
